<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Translate_model extends CI_Model {
    
    public $tb_translate = 'translate';
    
    function __construct() {
        parent::__construct();
        $this->load->library('session');
    }
    
    /* *****************************************************************************************************************
     * Name         : trans
     * -----------------------------------------------------------------------------------------------------------------
     * Description  :
     * -----------------------------------------------------------------------------------------------------------------
     * Params       :
     * -----------------------------------------------------------------------------------------------------------------
     * Return       :
     * -----------------------------------------------------------------------------------------------------------------
     * Warning      :
     * -----------------------------------------------------------------------------------------------------------------
     * Copyright    : TAOWEBSITE
     * -----------------------------------------------------------------------------------------------------------------
     * Created      : New  2014/06/15 (TienPham)  
     * *************************************************************************************************************** */
     
     public function trans($key_word = "")
     {
        $lang_current = $this->session->userdata('lang_current');
        $dbprefix = $this->config->item('dbprefix');
        $sql = "Select `translate` from " .$dbprefix.$this->tb_translate. " Where `key_word` = '$key_word' and `lang_code` = '" .$lang_current['lang_code']. "' Limit 1";
        $data = $this->db->query($sql)->row_array();
        if(!empty($data))
            $translate = $data['translate'];
        else
            $translate = $key_word;
        return $translate;
     }
     
     
}
